home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / siv / scroll2.inc < prev   
Text File  |  1994-04-25  |  6KB  |  262 lines

  1. ;       The SenSiv Scrolling Routines
  2. ────────────────────────────────────────────────────────────────────────────────
  3. ; Copyright 1994 by SiV productions, All rights reserved.
  4. ; Copyright 1994 by Tali Streit, All rights reserved.
  5. ────────────────────────────────────────────────────────────────────────────────
  6.  
  7. ;       Module2
  8.  
  9.  
  10.  
  11. ;  ▄▀▀▀▀▀▀▀▄
  12. ; █  │   │  █
  13. ; █  └─┬─┘  █
  14. ; █    │    █
  15. ; █    │    █
  16. ;  ▀▄▄▄▄▄▄▄▀
  17.  
  18. update_scroll2:
  19. updatescroll2:
  20. rendy2:
  21.         mov     bx, moveY2
  22.         or      bx, bx
  23.         js      donegY2
  24.  
  25.         and     bx, 15          ; do not handle scrolls larger then 16..
  26.         shl     bx, 1
  27.         mov     ax, rows[bx]
  28.         shr     bx, 1
  29.         add     SCRorigin2, ax
  30.         jmp     doposY2
  31.  
  32. donegY2: neg     bx
  33.         and     bx, 15          ; do not handle scrolls larger then 16...
  34.         shl     bx, 1
  35.         mov     ax, rows[bx]
  36.         sub     SCRorigin2, ax
  37.         shr     bx, 1
  38.         neg     bx
  39.  
  40. doposY2:
  41.         add     Ypos2, bx
  42.         add     indexY2, bx      ; The 16 counter index thing.
  43.         js      goUP2
  44.         cmp     indexY2, 16
  45.         jb      noYch2
  46. ;
  47. ;│   │ ┌── ┌  ┌
  48. ;└─┬─┘ │   ├──┤  ─┼─
  49. ;  │   └── ┘  ┘
  50. ;
  51.         mov     di, mapX        ;┌ update the map pointer.
  52.         add     source2, di     ;│
  53.  
  54.         mov     di, SCRorigin2   ;┌ calculate 128 pixels down from origin
  55.         add     di, 128*320      ;│
  56.  
  57.         sub     indexY2, 16     ;┌ Subtract the error term...
  58.         mov     bx, indexY2      ;│
  59.         shl     bx,1            ;│
  60.         sub     di, rows[bx]    ;│
  61.         sub     di, indexX2      ;│
  62.  
  63.         mov     si, source2
  64.     mov    ax, mapX
  65.  
  66.     add    si, ax        ;┌ point to the right line in the map
  67.     add    si, ax        ;│
  68.     add    si, ax        ;│
  69.     add    si, ax        ;│
  70.     add    si, ax        ;│
  71.     add    si, ax        ;│
  72.     add    si, ax        ;│
  73.     add    si, ax        ;│
  74.  
  75. ;        cmp     moveX2,0
  76. ;        jns     nodoY2
  77. ;        sub     di,16
  78. ;        dec     si
  79. ;nodoY2:
  80.         ; DI points to destination place...
  81.         ; SI pointe to source place...
  82.         add     si,mapoff
  83.         mov     cx,background2
  84.         call    do_row
  85.         jmp     noYch2
  86.  
  87. ;
  88. ;│   │ ┌── ┌  ┌
  89. ;└─┬─┘ │   ├──┤  ───
  90. ;  │   └── ┘  ┘
  91. ;
  92.  
  93. goUP2:   ; indexY should be negative...
  94.     mov    di,mapX
  95.         sub     source2,di
  96.  
  97.         mov     di,SCRorigin2
  98.     sub    di,16*320
  99.  
  100.         mov     bx, indexY2     ;┌ subtract error term.....
  101.     neg    bx        ;│
  102.     shl    bx, 1        ;│
  103.     add    di, rows[bx]    ;│
  104.         sub     di, indexX2     ;│
  105.  
  106.         add     indexY2, 16     ;┌ make indexY usable again....
  107.  
  108.         mov     si, source2     ;┌ make si point to top line.
  109. ;        sub     si, mapX        ;│
  110.  
  111.     ; DI points to destination place...
  112.         ; SI pointe to source place...
  113.     add    si, mapoff
  114.         mov     cx,background2
  115.         call    do_row
  116.  
  117. noYch2:
  118.  
  119. ;  ▄▀▀▀▀▀▀▀▄
  120. ; █  │   │  █
  121. ; █  └─┬─┘  █
  122. ; █  ┌─┴─┐  █
  123. ; █  │   │  █
  124. ;  ▀▄▄▄▄▄▄▄▀
  125. ;
  126. rendX2:
  127.         mov     bx, moveX2
  128.         or      bx, bx
  129.         js      donegX2
  130.  
  131.         and     bx, 15          ; do not handle scrolls larger then 16..
  132.         add     SCRorigin2, bx
  133.         jmp     doposX2
  134.  
  135. donegX2: neg     bx
  136.         and     bx, 15          ; do not handle scrolls larger then 16...
  137.         neg     bx
  138.         add     SCRorigin2, bx
  139.  
  140. doposX2: add     Xpos2, bx
  141.         add     indexX2, bx      ; The 16 counter index thing.
  142.         js      goback2
  143.         cmp     indexX2, 16
  144.         jb      noXch2
  145. ;
  146. ;└┐ ┌┘ ┌── ┌  ┌
  147. ; ├─┤  │   ├──┤  ─┼─
  148. ;┌┘ └┐ └── ┘  ┘
  149. ;
  150.         inc     source2          ; Update the source pointer (map)
  151.  
  152.         mov     di, SCRorigin2    ;┌ calculate 128 pixels right from origin
  153.     add    di, 128      ;│
  154.  
  155.         sub     indexX2, 16      ;┌ Subtract the error term...
  156.         sub     di, indexX2      ;│
  157.         mov     bx, indexY2      ;│
  158.         shl     bx,1            ;│
  159.         sub     di, rows[bx]    ;│
  160.  
  161.         mov     si, source2
  162.     add    si, 8
  163.  
  164.         ; DI points to destination place...
  165.         ; SI pointe to source place...
  166.     add    si,mapoff
  167.         mov     cx,background2
  168.         call    do_col
  169.         jmp     noXch2
  170.  
  171. ;
  172. ;│   │ ┌── ┌  ┌
  173. ;└─┬─┘ │   ├──┤  ───
  174. ;┌─┴─┐ └── ┘  ┘
  175. ;│   │
  176.  
  177. goback2:   ; indexX should be negative...
  178.         dec     source2
  179.  
  180.         mov     di,SCRorigin2
  181.     sub    di,16
  182.  
  183.         mov     bx, indexX2      ;┌ subtract error term.....
  184.     neg    bx        ;│
  185.     add    di, bx        ;│
  186.         mov     bx, indexY2      ;│
  187.         shl     bx,1            ;│
  188.         sub     di, rows[bx]    ;│
  189.  
  190.         add     indexX2, 16      ;┌ make indexX usable again....
  191.  
  192.         mov     si, source2      ;┌ make si point to left col
  193. ;        dec     si              ;│
  194.  
  195.     ; DI points to destination place...
  196.         ; SI pointe to source place...
  197.     add    si, mapoff
  198.         mov     cx,background2
  199.         call    do_col
  200.  
  201. noXch2:
  202.         ret
  203.  
  204. Check2:
  205.         mov     bx,Xpos2
  206.         add     bx,MoveX2
  207.         cmp     bx,maxXpos
  208.         jl      _noXwrap2
  209.         neg     MoveX2
  210. _noXwrap2:
  211.         cmp     bx,minXpos
  212.         jg      noXwarp22
  213.         neg     MoveX2
  214. noXwarp22:
  215.         mov     bx,Ypos2
  216.         add     bx,MoveY2
  217.         sub     bx,16
  218.         cmp     bx,maxYpos
  219.         jl      _noYwarp2
  220.         neg     MoveY2
  221. _noYwarp2:
  222.         cmp     bx,minYpos
  223.         jg      noYwarp22
  224.         neg     MoveY2
  225. noYwarp22:
  226.         ret
  227.  
  228. init_scroll2:
  229. initscroll2:     ; this takes Xpos2 and Ypos2 and calculates the rest.
  230. ;        mov     cx,mapx        ┌ this is done in initscroll1
  231. ;        sub     cx,8           │
  232. ;        shl     cx,4           │
  233. ;        mov     maxxpos,cx     │
  234. ;                               │
  235. ;        mov     ax,mapy        │
  236. ;        sub     ax,8           │
  237. ;        shl     ax,4           │
  238. ;        mov     maxYpos,ax     │
  239.  
  240.         mov     bx,Ypos2
  241.         shl     bx,1
  242.         mov     di,rows[bx]
  243.         add     di,Xpos2
  244.         mov     SCRorigin2,di
  245.         mov     bx,Xpos2
  246.         and     bx,15
  247.         mov     indexX2,bx
  248.         mov     bx,Ypos2
  249.         and     bx,15
  250.         mov     indexY2,bx
  251.  
  252.         mov     bx, Ypos2
  253.         shr     bx, 4
  254.         mov     ax, mapX
  255.         mul     bx
  256.         mov     source2, ax
  257.         mov     bx, Xpos2
  258.         shr     bx, 4
  259.         add     source2, bx
  260.         ret
  261.  
  262.